home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2002 January / maximum-cd-2002-01.iso / Files / Mechwarrior 4 Mapping / MW4Editor.exe / content / ABLScripts / GenericScripts / SentryReinforcement.tpl < prev    next >
Encoding:
Text File  |  2001-07-16  |  7.7 KB  |  237 lines

  1.  
  2. UIFIELDS
  3. {
  4. FIELD<         INT,attackRange,"Attack Range",500>;        // At what range do I start shooting?
  5. FIELD<         INT,withdrawRange,"Withdraw Range",750>;        // At what range do I withdraw from combat entirely?
  6. FIELD<          INT,piloting,"Piloting Skill",50>;            // Piloting skill
  7. FIELD<          INT,gunnery,"Gunnery Skill",50>;            // Gunnery skill/chance to hit
  8. FIELD<          FLOAT,minDelay,"Minimum fire Delay",1.0>;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  9. FIELD<          FLOAT,maxDelay,"Maximum fire Delay",2.0>;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  10. FIELD<          INT,eliteLevel,"Elite Level",60>;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  11.                                                     // and other things.  It indicates a general level of combat experience.
  12. FIELD<           INT,isShotRadius,"Is Shot Radius",120>;        // How far away from me will I detect an enemy shot?        
  13. FIELD<INT,    takeOffDistance,"Take Off Distance (ignored if not a plane)",160>;
  14. FIELD<INT,    attackThrottle,"Percent throttle when in combat",80>;
  15.  
  16. FIELD<INT, speed,"Movement Speed",600>;        
  17.  
  18. FIELD<INT, DestX,"X coordinate of destination (-1 = none)",-1>;
  19. FIELD<INT, DestY,"Y coordinate of destination (-1 = none)",-1>;
  20. FIELD<INT, DestZ,"Z coordinate of destination (-1 = none)",-1>;
  21. FIELD<INT, trigger,"ID of trigger that makes the unit wake up",1>;
  22.  
  23. }
  24.  
  25.  
  26. //------------------------------------------------------------------
  27. // NOTE: The fsm name below MUST be changed in order for the
  28. // script to be considered a unique entity!
  29.  
  30. fsm Generic_SentryReinforcement : integer;
  31.  
  32.  
  33. //------------------------------------------------------------------
  34.  
  35. // Generic_SentryReinforcement:
  36. //   Performs sentry, attacking anything that comes near.
  37. //   Once a trigger is set, goes to a predefined point and
  38. //   attacks anything within range at that point.
  39.  
  40. //------------------------------------------------------------------
  41.  
  42.  
  43.  
  44. //------------------------------------------------------------------
  45. //     Constants
  46. //------------------------------------------------------------------
  47.  
  48.     const
  49.         #include_ <content\ABLScripts\mwconst.abi>
  50.  
  51. //------------------------------------------------------------------
  52. //     Types
  53. //------------------------------------------------------------------
  54.  
  55.     type
  56.         #include_ <content\ABLScripts\mwtype.abi>
  57.     
  58.  
  59. //------------------------------------------------------------------
  60. //     Variables
  61. //------------------------------------------------------------------
  62.  
  63.     var
  64.     static integer            attackRange1;        // At what range do I start shooting when I'm attacking?
  65.     static integer            withdrawRange1;        // At what range do I give up?
  66.     static integer            attackRange2;        // At what range do I start shooting (as a reinforcement)?
  67.     static integer            withdrawRange2;        // At what range do I stop shooting (as a reinforcement)?
  68.     static integer            triggerID;            // The index of my global trigger
  69.     static LocPoint            destination;        // The destination to move to when ready
  70.                                                                 
  71.     static integer            piloting;            // Piloting skill
  72.     static integer            gunnery;            // Gunnery skill/chance to hit
  73.     static real                minDelay;            // Minimum amount of time I will wait between shots once a weapon is reloaded
  74.     static real                maxDelay;            // Maximum amount of time I will wait between shots once a weapon is reloaded
  75.     static integer             speed;                // What speed so I move at?
  76.     static integer             elitelevel;            // Elite level.  This helps determine tactics, defensive manuevers, opportunity fire
  77.                                                 // and other things.  It indicates a general level of combat experience.
  78.     static integer            attackThrottle;        // My attack throttle
  79.     static integer            findTypes;            // What kind of enemies to look for
  80.  
  81.      static integer            isshotradius;        // How far away from me will I detect an enemy shot?
  82.  
  83.     static integer             attackSound;        // The attack sound I play when I first attack
  84.     static integer             deathSound;            // The sound I play when I die
  85.  
  86.     static integer            mood;                // My default mood.
  87.  
  88.     static integer            takeOffDistance;    // My take-off distance if I'm an airplane (ignored if not an airplane)
  89.  
  90. //------------------------------------------------------------------
  91. //     Init: my initialization function
  92. //------------------------------------------------------------------
  93.  
  94. function Init;
  95.     code
  96.  
  97.         // Variables set by editor
  98.         attackRange        = <attackRange>;
  99.         withdrawRange    = <withdrawRange>;
  100.         takeOffDistance    = <takeOffDistance>;
  101.          piloting        = <piloting>;
  102.         gunnery            = <gunnery>;
  103.         minDelay        = <minDelay>;
  104.         maxDelay        = <maxDelay>;
  105.         eliteLevel        = <eliteLevel>;
  106.         isShotRadius    = <isShotRadius>;
  107.     attackThrottle    = <attackThrottle>;
  108.  
  109.         triggerID        = <trigger>;
  110.       destination[0]    = <DestX>;
  111.         destination[1]    = <DestY>;
  112.         destination[2]    = <DestZ>;
  113.         
  114.     attackRange2    = attackRange1;
  115.     withdrawRange2    = withdrawrange1;
  116.  
  117.         // driver settings
  118.         attackSound        = -1; // no sound
  119.         deathSound        = -1; // no sound
  120.         mood            = NEUTRAL_START;
  121.         findTypes        = FT_DEFAULT;
  122.  
  123. endfunction;
  124.  
  125. //------------------------------------------------------------------
  126. //    StartState: my initial state
  127. //------------------------------------------------------------------
  128.  
  129. state StartState;
  130.  
  131.     code
  132.         SetFiringDelay            (ME,minDelay,maxDelay);
  133.         SetIgnoreFriendlyFire    (ME,true);
  134.         SetIsShotRadius            (ME,isShotRadius);
  135.         SetEntropyMood            (ME,mood);
  136.         SetCurMood                (ME,mood);
  137.         SetSkillLevel            (ME,piloting,gunnery,eliteLevel);
  138.         SetAttackThrottle        (ME,attackThrottle);
  139.                 
  140.         if (orderTakeOff(takeOffDistance) == true) then
  141.             trans WaitState;
  142.         endif;
  143.  
  144. endstate;
  145.  
  146. //------------------------------------------------------------------
  147. //    WaitState: wait something to happen (my original state)
  148. //------------------------------------------------------------------
  149.  
  150. state WaitState;
  151.     code
  152.         if (GetGlobalTrigger(triggerID)) then
  153.             trans MoveToPointState;
  154.         endif;
  155.  
  156.         if (FindEnemy(attackRange1,findTypes)) then
  157.             trans Attack1State;
  158.         endif;
  159.  
  160.         OrderMoveLookOut;
  161.  
  162. endstate;
  163.  
  164. //------------------------------------------------------------------
  165. //    Attack1State: attack someone (before I'm called as a reinforcement)
  166. //------------------------------------------------------------------
  167.  
  168. state Attack1State;
  169.     code
  170.         if (LeaveAttackState(withdrawRange1)) then
  171.             trans WaitState;
  172.         endif;
  173.  
  174.         if (GetGlobalTrigger(triggerID)) then
  175.             trans Attack2State;
  176.         endif;
  177.  
  178.         if (attackSound <> -1) then    
  179.             PlaySoundOnce(attackSound);
  180.         endif;
  181.  
  182.         OrderAttack(TRUE);
  183.  
  184. endstate;
  185.  
  186. //------------------------------------------------------------------
  187. //    MoveToPointState: go to the destination, and attack when we get there
  188. //------------------------------------------------------------------
  189.  
  190. state MoveToPointState;
  191.     code
  192.         if (OrderMoveToLocPoint(destination,speed,true,true)) then
  193.             OrderStopAttacking;
  194.  
  195.             if (FindEnemy(attackRange2,findTypes)) then
  196.                 trans Attack2State;
  197.             endif;
  198.         endif;
  199.  
  200. endstate;
  201.  
  202. //------------------------------------------------------------------
  203. //    Attack2State: attack a target (after I'm called as a reinforcement)
  204. //------------------------------------------------------------------
  205.  
  206. state Attack2State;
  207.     code
  208.         if (LeaveAttackState(withdrawRange2)) then
  209.             trans MoveToPointState;
  210.         endif;
  211.  
  212.         if (attackSound <> -1) then    
  213.             PlaySoundOnce(attackSound);
  214.         endif;
  215.  
  216.         OrderAttack(TRUE);
  217.  
  218. endstate;
  219.  
  220. //------------------------------------------------------------------
  221. //    DeadState: OK, I kicked the bucket.
  222. //------------------------------------------------------------------
  223.  
  224. state DeadState;
  225.   code
  226.         if (deathSound <> -1) then    
  227.             PlaySoundOnce(deathSound);
  228.         endif;        
  229.  
  230.         orderDie;
  231.  
  232. endstate;
  233.  
  234.  
  235. endfsm.
  236.  
  237.